feat: add global --verbose flag for HTTP debugging#370
Conversation
|
Welcome to the Microcks community! 💖 Thanks and congrats 🎉 for opening your first pull request here! Be sure to follow the pull request template or please update it accordingly. Hope you have a great time there! |
|
@Aditya200247 Can you please sign-off your commits? It's mendatory to sign-off commits while contributing to CNCF projects. |
The old approach used a config.Verbose global and scattered httputil.DumpRequestOut/DumpResponse calls across every method. Replace it with a small loggingTransport that wraps the HTTP client's RoundTripper once at construction time. - Logs >> METHOD URL and each request header to stderr - Redacts the Authorization header value - Logs << STATUS after each response - Removes the Verbose global and DumpRequestIfRequired / DumpResponseIfRequired helpers from pkg/config Signed-off-by: Aditya <thakuradityakumar17@gmail.com>
Also remove the now-dead config.Verbose assignments from all command Run functions - the flag value flows through ClientOptions.Verbose directly into the HTTP client transport. Signed-off-by: Aditya <thakuradityakumar17@gmail.com>
- Add verbose bool field to loggingTransport; RoundTrip is a no-op when verbose is false so the transport is always safe to install - Add verbose param to NewMicrocksClient and NewKeycloakClient so the direct-auth code path (--microcksURL + --keycloakClientId) also logs when -v is passed - Pass c.Verbose into the internal keycloak client used for token refresh so logging is consistent across the whole session - Remove the local --verbose flag from import-dir (it conflicted with the root persistent flag); globalClientOpts.Verbose now drives both HTTP logging and the file-listing output - Fix TestLoggingTransportSilentWhenVerboseFalse: read stderr before closing the pipe and assert zero bytes written - Drop deprecated filepath.HasPrefix in importDir_test.go - Remove the benchmark that was noise for this PR Signed-off-by: Aditya <thakuradityakumar17@gmail.com>
- Remove dead ImportError type from importDir.go - Add direct-auth path (--microcksURL + keycloak flags) to import-dir so it matches the other commands (import, test, import-url) - Redirect verbose diagnostic output to stderr per issue spec - Fix silent fmt.Errorf in executor.go (was swallowing the error) replaced with fmt.Fprintf(os.Stderr, ...) Signed-off-by: Aditya <thakuradityakumar17@gmail.com>
563459b to
775349b
Compare
|
Hey @Harsh4902 , |
|
@Aditya200247 Can you please rebase the PR branch with |
|
hi @Harsh4902 can I resolve merge conflict thorough creating a PR using his commits cherry pick? is Aditya is not available . as it's pending from long time |
|
Hi @Harsh4902, |
go test -v ./pkg/connectors
=== RUN TestDownloadArtifactReturnsResponseBody
--- PASS: TestDownloadArtifactReturnsResponseBody (0.00s)
=== RUN TestLoggingTransportSilentWhenVerboseFalse
--- PASS: TestLoggingTransportSilentWhenVerboseFalse (0.00s)
=== RUN TestLoggingTransportRedactsAuth
--- PASS: TestLoggingTransportRedactsAuth (0.00s)
PASS
ok github.com/microcks/microcks-cli/pkg/connectors 1.298s
go test -v ./cmd
=== RUN TestImportDirectory
=== RUN TestImportDirectory/successful_import_of_all_files
--- PASS: TestImportDirectory/successful_import_of_all_files (0.00s)
=== RUN TestImportDirectory/partial_failure
--- PASS: TestImportDirectory/partial_failure (0.00s)
=== RUN TestImportDirectory/recursive_scan
--- PASS: TestImportDirectory/recursive_scan (0.00s)
=== RUN TestImportDirectory/pattern_filtering
--- PASS: TestImportDirectory/pattern_filtering (0.00s)
--- PASS: TestImportDirectory (0.00s)
=== RUN TestValidateDirectory
--- PASS: TestValidateDirectory (0.00s)
=== RUN TestFindSpecificationFilesWithFS
--- PASS: TestFindSpecificationFilesWithFS (0.00s)
=== RUN TestDetectFileTypeWithLogic
--- PASS: TestDetectFileTypeWithLogic (0.00s)
=== RUN TestNewImportDirCommand
--- PASS: TestNewImportDirCommand (0.00s)
=== RUN TestImportResult
--- PASS: TestImportResult (0.00s)
--- FAIL: TestDeleteContext (0.00s) ← pre-existing upstream failure (unrelated to this PR)
open ./testdata/local.config: The system cannot find the path specified.
Description
Added a global -v / --verbose persistent flag to the root command to help users debug local connection issues.
Implemented a custom RoundTripper for the HTTP client that logs the request method, target URL, and response status to stderr.
Added security masking to ensure sensitive headers (specifically the Authorization header) are redacted and not printed to the console.
Related issue(s)
resolved #347